package jm.easyconfig.standby;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

import jm.easyconfig.CfgAdminServlet;
import jm.easyconfig.CfgContextEnvironmentAware;

@SpringBootApplication
public class EasyconfigStandbyApplication {

	public static void main(String[] args) {
		SpringApplication.run(EasyconfigStandbyApplication.class, args);
	}

	@Bean
	@ConditionalOnMissingBean(CfgContextEnvironmentAware.class)
	CfgContextEnvironmentAware cfgContextEnvironmentAware() {
		return new CfgContextEnvironmentAware();
	}

	@Bean
	public ServletRegistrationBean<CfgAdminServlet> cfgAdminServlet() {
		ServletRegistrationBean<CfgAdminServlet> bean = new ServletRegistrationBean<CfgAdminServlet>(
				new CfgAdminServlet(), "/*");
		bean.setName("easyconfig-admin-servlet");
		return bean;
	}
}
